package com.zhuss.team.question;

import com.zhuss.bean.bo.team.question.CreateQuestionBo;
import com.zhuss.bean.bo.team.question.DeleteQuestionBo;
import com.zhuss.bean.bo.team.question.UpdateQuestionBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.WpsException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author: zhushanshuo
 * @Date: 2020/3/26 12:55
 */
@Component("questionOperateService")
public class QuestionOperateService implements OperateService<Void,Object> {

    @Autowired
    @Qualifier("questionCreate")
    private Processor<Object, CreateQuestionBo> questionCreate;

    @Autowired
    @Qualifier("questionUpdate")
    private Processor<Object, UpdateQuestionBo> questionUpdate;

    @Autowired
    @Qualifier("questionDelete")
    private Processor<Object, DeleteQuestionBo> questionDelete;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Void create(Object o) throws WpsException {
        CreateQuestionBo bo = (CreateQuestionBo) o;
        questionCreate.process(bo);
        return null;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object o) throws WpsException {
        UpdateQuestionBo bo = (UpdateQuestionBo) o;
        questionUpdate.process(bo);
        return null;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Void delete(Object o) throws WpsException {
        DeleteQuestionBo bo = (DeleteQuestionBo) o;
        questionDelete.process(bo);
        return null;
    }
}
